<?php
# 1. 静态属性用于保存类的公有数据
# 2. 静态方法里面只能访问静态属性
# 3. 静态成员不需要实例化对象就可以访问
# 4. 类的内部可以通过self或static关键访问自身静态成员
# 5. 可以通过parent访问父类的静态成员
# 6. 可以通过类的名称在类定义外部访问静态成员
class Human {
    public $name;
    public $height;
    public $weight;
    public static $value = "Static value in human class";

    public function eat($food) {
        echo $this->name . "'s eating " . $food . "\n";
    }
}
class NbaPlayer extends Human {
    # define attribute
    public $team = "Bull";
    public $playernumber = "23";

    # defin static
    public static $president = "David Stern";

    public static function changePresident($newPresident) {
        #self::$president = $newPresident ;
        static::$president = $newPresident ;
        echo parent::$value . "</br>"; 
    }

    #define default 
    public function __construct($name, $height, $weight, $playernumber) {
        echo "In Nbaplayer constructor\n </br>";
        $this->name = $name;
        $this->height = $height;
        $this->weight = $weight;
        $this->playernumber = $playernumber;
    }

    public function __destruct() {
        echo "Destroying" . $this->name . "\n";
    }
    # define function
    public function run() {
        echo "Running\n";
    }

    public function jump() {
        echo "jumping\n";
    }

    public function dribble() {
        echo "dribbling\n";
    }

    public function shoot() {
        echo "shooting\n";
    }

    public function dunk() {
        echo "dunking\n";
    }

    public function pass() {
        echo "passing\n";
    }
}

echo NbaPlayer::$president. " Before change" . "</br>";
NbaPlayer::changePresident("Adam Silver");
echo "<br>";
echo NbaPlayer::$president;



?>
